package com.util;
import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

public class FileOperation {

public static void main(String[] args) {

String src = "d:/master_boss";

String dec = "d:/master_boss.txt";

try {

FileInputStream in = new FileInputStream(src);

// File file = new File&#40;dec&#41;;

// if(!file.exists())

// file.createNewFile&#40;&#41;;

FileOutputStream out = new FileOutputStream(dec);

byte buffer[] = new byte[1024];

int count,i;

while((count=in.read(buffer))!=-1){

// for循环保证只写入count个byte, 否则会写入1024个byte

for(i=0; i<count; i++){

out.write(buffer[i]);

}

}

in.close();

out.close();

System.out.println("Success!");

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}